/*
 * @SuperTV All Rights Reserved
 */

package com.aube.interact.model;

import org.json.JSONObject;

import java.io.Serializable;

/**
 * Created by huyaonan on 15/11/7.
 */
public class PicItem implements Serializable {

    public static final String IMG_TAG = "tag";
    public static final String IMG_URL = "main";

    /**
     * if type = main, it is the image to be shown in left part
     * if type = tag, it is the flag to be shown in top-left
     * if type=null, it is just the child branch of
     */
    public String type="";
    public String picurl="";
    public int width=0;
    public int height=0;

    /**
     * 图片超链接和描述
     */
    public String h5url="";
    public String desc="";

    public static PicItem parse(JSONObject jsonObject) {
        if(jsonObject == null)
            return new PicItem();
        PicItem item = new PicItem();
        item.type = jsonObject.optString("type");
        item.picurl = jsonObject.optString("picurl");
        item.h5url = jsonObject.optString("h5url");
        item.desc = jsonObject.optString("desc");
        item.width = jsonObject.optInt("width");
        item.height = jsonObject.optInt("height");
        return item;
    }

}
